<style>
 .user_item {
        display: flex;
        width: 31%;
        padding-right: 10px;
        padding: 20px 0;

        .user_item_left {
            padding-right: 10px;

            img {
                border-radius: 100px;
                height: 85px;
                width: 85px;
            }
        }

        .user_item_right {
            display: flex;
            flex-direction: column;
            padding: 3px;

            .user_item_right_top {

                color: #18191c;
                font-size: 18px;
            }

            .user_item_right_mid {
                padding: 3px 0;
                font-size: 12px;
                color: #62666c;
                display: flex;
                justify-content: space-between;
            }

            .user_item_right_bottom {
                padding: 3px 0;

                button {
                    border: none;
                    border-radius: 5px;
                    background: #f1f2f3;
                    padding: 5px 25px;
                }

                button:hover {
                    background: #4eabe6;
                    color: white;
                }

                button:active {
                    font-size: 11px;
                }
            }
        }
    }
</style>

<template>
    <div class="user_item" @click="toUserDetail(item)">
        <div class="user_item_left">
            <img :src="userInfo.avatar ? userInfo.avatar : 'https://avatars.githubusercontent.com/u/10110001?v=4'" alt="">
            </img>
        </div>
        <div class="user_item_right">
            <div class="user_item_right_top">{{ userInfo.nickname }}</div>
            <div class="user_item_right_mid">
                <span>{{ userInfo.fensNum ? userInfo.fensNum : 0 }}粉丝</span>
                <span style="width: 10px;"></span>
                <span>{{ userInfo.articleNum ? userInfo.articleNum : 0 }}个帖子</span>
            </div>
            <div class="user_item_right_bottom">
                <button>
                    关注
                </button>
            </div>
        </div>
    </div>
</template>
<script>
import { newPage } from '@/utils/commonFunction';
import request from '@/utils/request';
export default {
    name: 'userSearchResult',
    props: {
        userInfo: {
            type: Object,
            default: null
        }
    },
    data() {
    },
    methods:{
        follow(flag) {
            request.post("/user_follows", {
                followedId: this.userInfo.id,
                isFollow: flag
            }).then(res => {
                if (res.code == 200) {
                    this.isFollow = !this.isFollow;
                }
            })
        },
        toUserDetail(item){
            newPage(`/personCenter/${item.id}`)
        },
    }
}
</script>